package day1.session;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/day1/session/login.do")
public class LoginServ extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf8");
        String user=req.getParameter("user");
        System.out.println("user:"+user);
        req.setAttribute("u",user);
        HttpSession session=req.getSession();
        session.setAttribute("u",user);
        req.getRequestDispatcher("/day1/session/success.jsp").forward(req,resp);
    }
}
